package com.echat.serviceapigateway.security.service.impl;

import com.echat.commonlib.exception.exc.ValidateFailedException;
import com.echat.serviceapigateway.security.mapper.ServiceMapper;
import com.echat.serviceapigateway.security.model.authorization.Service;
import com.echat.serviceapigateway.security.service.ServiceService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by chenmohan on 2018/09/18
 *
 * @description
 */
@org.springframework.stereotype.Service
public class ServiceServiceImpl implements ServiceService {

    @Autowired
    ServiceMapper serviceMapper;

    @Override
    public List<Service> listAll() {
        return serviceMapper.selectAll();
    }

    @Override
    public Service getById(Long id) {
        if (id == null) {
            throw new ValidateFailedException("id must be not null");
        }
        return serviceMapper.selectByPrimaryKey(id);
    }
}
